﻿Function Get-EscapedJSONBody($originalBody)
{
    
    $newBody=$originalBody

    if($null -eq $newBody -or $newBody.GetType().Name -eq "DBNull")
    {
         $newBody="null"    
    }

    #$newBody=$newBody -replace '"', "\\`""
    $newBody=$newBody -replace "\\", "\\\\"
    $newBody=$newBody -replace '"',"\`""
    $newBody=$newBody -replace "/", "\\/"
    $newBody=$newBody -replace "`r", "\\r"
    $newBody=$newBody -replace "`f", "\\f"
    $newBody=$newBody -replace "`n", "\\n"
    $newBody=$newBody -replace "`r", "\\r"
    $newBody=$newBody -replace "`t", "\\t"
    $newBody=$newBody -replace "é", "e"
    $newBody=$newBody -replace "ê", "e"
    $newBody=$newBody -replace "ë", "e"
    $newBody=$newBody -replace "è", "e"
    $newBody=$newBody -replace "ç", "c"
    $newBody=$newBody -replace "à", "a"
    $newBody=$newBody -replace '“', "\\`""
    $newBody=$newBody -replace '”', "\\`""
    $newBody=$newBody -replace [char]160, ""

    $newBody

}